package com.baidu.speech.qr_code.ui.notifications;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.baidu.speech.qr_code.R;
import com.baidu.speech.qr_code.ui.home.Core_log;
import com.baidu.speech.qr_code.ui.home.Custom_code_Home;

import org.litepal.LitePal;

import java.util.Collections;
import java.util.List;

public class Custom_code extends AppCompatActivity {

    private ListView lv_custom_code;
    private TextView tv_lsjl;
    private TextView tv_noitfcontent;
    private List<Custom_code_Home>coreLogList= LitePal.findAll(Custom_code_Home.class);
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_code);
        initView();
    }

    private void initView() {
        lv_custom_code = (ListView) findViewById(R.id.lv_custom_code);
        MyAdapter myAdapter=new MyAdapter();
        lv_custom_code.setAdapter(myAdapter);
        Collections.reverse(coreLogList);
    }
    class MyAdapter extends BaseAdapter{

        @Override
        public int getCount() {
            return coreLogList.size();
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            View view1 = View.inflate(Custom_code.this, R.layout.historical_records_son, null);
            tv_lsjl = view1.findViewById(R.id.tv_lsjl);
            tv_noitfcontent = view1.findViewById(R.id.tv_noitfcontent);
            tv_lsjl.setText(coreLogList.get(i).getTime());
            tv_noitfcontent.setText(coreLogList.get(i).getEd_srk());
            return view1;
        }
    }
}